//
// Created by francklinson on 2021/9/1 AT 0:41.
//
#include <iostream>
#include <vector>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <algorithm>
#include <functional>
#include <climits>

using namespace std;

class Solution {
public:
    int compareVersion(string version1, string version2) {
        int n = static_cast<int>(version1.length()), m = static_cast<int>(version2.length());
        int i = 0, j = 0;
        while (i < n || j < m) {
            int x = 0;
            for (; i < n && version1[i] != '.'; ++i) {
                x = x * 10 + version1[i] - '0';
            }
            ++i; // 跳过点号
            int y = 0;
            for (; j < m && version2[j] != '.'; ++j) {
                y = y * 10 + version2[j] - '0';
            }
            ++j; // 跳过点号
            if (x != y) {
                return x > y ? 1 : -1;
            }
        }
        return 0;
    }
};


int main() {
    Solution solution;
    cout << solution.compareVersion("7.5.2.4", "7.5.3") << endl;
    cout << solution.compareVersion("1.01", "1.001") << endl;
    cout << solution.compareVersion("1.0", "1.0.0") << endl;
    return 0;
}

